import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:znmm/UI/A_Common/buttons/easy_button/easy_elevated_button.dart';
import 'package:znmm/config/app_asset.dart';
import 'package:znmm/config/app_color.dart';
import 'package:znmm/config/app_gaps.dart';
import '../A_Common/custom_behavior.dart';
import 'login_view.dart';

/// 登录注册枚举类型
enum LoginType {
  pwdLogin,
  phoneLogin,
  emailLogin,
  subLogin,
  register,
}

class LoginPage extends StatefulWidget {
  const LoginPage({super.key});

  @override
  State<LoginPage> createState() => _LoginPageState();
}

class _LoginPageState extends State<LoginPage> {
  @override
  Widget build(BuildContext context) {
    return AnnotatedRegion(
      value: SystemUiOverlayStyle.dark,
      child: Scaffold(
        backgroundColor: AppColor.white,
        body: Container(
          alignment: Alignment.center,
          padding:
              EdgeInsets.only(right: 20.w, left: 20.w, top: 80.w, bottom: 20.w),
          child: CustomBehavior(
            child: SingleChildScrollView(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  const _TopView(),
                  AppGaps.vGaps30w,
                  EasyElevatedButton(
                    label: '密码登录',
                    isRounded: true,
                    color: AppColor.greyF3F4F8,
                    labelColor: AppColor.black,
                    width: double.infinity,
                    height: 44,
                    icon: Image.asset(
                      AppAsset.account,
                      width: 25,
                      height: 25,
                    ),
                    onPressed: () {
                      Get.to(const LoginView(), arguments: LoginType.pwdLogin);

                      //跳到首页
                      //Get.offNamedUntil(RouteNames.homeRoute, (route) => false);
                    },
                  ),
                  AppGaps.vGaps15w,
                  EasyElevatedButton(
                    label: '手机登录',
                    isRounded: true,
                    color: AppColor.greyF3F4F8,
                    labelColor: AppColor.black,
                    width: double.infinity,
                    height: 44,
                    icon: Image.asset(
                      AppAsset.mobile,
                      width: 25,
                      height: 25,
                    ),
                    onPressed: () {
                      // Get.to(const LoginView(),
                      //     arguments: LoginType.phoneLogin);
                    },
                  ),
                  AppGaps.vGaps15w,
                  EasyElevatedButton(
                    label: '邮件登录',
                    isRounded: true,
                    color: AppColor.greyF3F4F8,
                    labelColor: AppColor.black,
                    width: double.infinity,
                    height: 44,
                    icon: Image.asset(
                      AppAsset.sms,
                      width: 25,
                      height: 25,
                    ),
                    onPressed: () {
                      // Get.to(const LoginView(),
                      //     arguments: LoginType.emailLogin);
                    },
                  ),
                  AppGaps.vGaps15w,
                  EasyElevatedButton(
                    label: '子账号登录',
                    isRounded: true,
                    color: AppColor.greyF3F4F8,
                    labelColor: AppColor.black,
                    width: double.infinity,
                    height: 44,
                    icon: Image.asset(
                      AppAsset.subAccount,
                      width: 25,
                      height: 25,
                    ),
                    onPressed: () {
                      //Get.to(const LoginView(), arguments: LoginType.subLogin);
                    },
                  ),
                  AppGaps.vGaps50w,
                ],
              ),
            ),
          ),
        ),
      ),
    );
  }

  // Widget _button(String textStr, String urlPathStr, {VoidCallback? onTap}) {
  //   return MyIconTextButton(
  //     height: 50.w,
  //     text: textStr,
  //     url: urlPathStr,
  //     iconWidth: 24.w,
  //     iconHeight: 24.w,
  //     direction: Direction.left,
  //     background: AppColor.greyF3F4F8,
  //     borderRadius: BorderRadius.circular(25.w),
  //     style: TextStyle(
  //       color: AppColor.black,
  //     ),
  //     onTap: onTap,
  //   );
  // }
}

/// 顶部
class _TopView extends StatelessWidget {
  const _TopView({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Image.asset(
              AppAsset.imageLogo,
              fit: BoxFit.contain,
            ),
            AppGaps.hGaps10w,
            Text(
              "Glassesin",
              style: TextStyle(
                color: AppColor.black,
                fontSize: 30.sp,
              ),
            ),
          ],
        ),
        AppGaps.vGaps20w,
        Text(
          "开始使用",
          style: TextStyle(
            color: AppColor.black,
            fontSize: 35.sp,
          ),
        ),
        AppGaps.vGaps10w,
        Text(
          "登录以继续使用Glassesin",
          style: TextStyle(
            color: AppColor.grey8787,
            fontSize: 16.sp,
          ),
        ),
      ],
    );
  }
}
